package org.nuonuo.sdk.model.req;

import org.nuonuo.sdk.jackson.JsonMapper;
import org.nuonuo.sdk.valid.Validator;

import javax.validation.ValidationException;

/**
 * @Version 1.0
 * @Author az
 * @Date 2024-04-08 14:17:10
 * @ClassName ReInvoiceReq
 * @Description
 */
public class ReInvoiceReq extends Validator {

    /**
     * 发票流水号，流水号和订单号两字段二选一，同时存在以流水号为准
     */
    private String fpqqlsh;

    /**
     * 订单
     */
    private String orderno;

    /**
     * 指定发票代码（票种为c普纸、f收购纸票时可以指定卷开票） 非必填
     */
    private String nextInvoiceCode;

    /**
     * 发票起始号码（票种为c普纸、f收购纸票） 当指定代码有值时，发票起始号码必填
     */
    private String invoiceNumStart;

    /**
     * 发票终止号码（票种为c普纸、f收购纸票） 当指定代码有值时，发票终止号码必填
     */
    private String invoiceNumEnd;

    /**
     * 数电账号，数电发票支持指定数电账号重试开票，非必填
     */
    private String digiAccount;

    @Override
    public void valid() {
        if (JsonMapper.isEmpty(fpqqlsh) && JsonMapper.isEmpty(orderno))
            throw new ValidationException("流水号和订单号两字段二选一");
        if (JsonMapper.isEmpty(nextInvoiceCode)) return;
        if (JsonMapper.isEmpty(invoiceNumStart)) throw new ValidationException("发票起始号码必填");
        if (JsonMapper.isEmpty(invoiceNumEnd)) throw new ValidationException("发票终止号码必填");
    }

    public String getFpqqlsh() {
        return fpqqlsh;
    }

    public void setFpqqlsh(String fpqqlsh) {
        this.fpqqlsh = fpqqlsh;
    }

    public String getOrderno() {
        return orderno;
    }

    public void setOrderno(String orderno) {
        this.orderno = orderno;
    }

    public String getNextInvoiceCode() {
        return nextInvoiceCode;
    }

    public void setNextInvoiceCode(String nextInvoiceCode) {
        this.nextInvoiceCode = nextInvoiceCode;
    }

    public String getInvoiceNumStart() {
        return invoiceNumStart;
    }

    public void setInvoiceNumStart(String invoiceNumStart) {
        this.invoiceNumStart = invoiceNumStart;
    }

    public String getInvoiceNumEnd() {
        return invoiceNumEnd;
    }

    public void setInvoiceNumEnd(String invoiceNumEnd) {
        this.invoiceNumEnd = invoiceNumEnd;
    }

    public String getDigiAccount() {
        return digiAccount;
    }

    public void setDigiAccount(String digiAccount) {
        this.digiAccount = digiAccount;
    }
}
